<template>
  <div class="app-container flex-column ">
    <div class="flex-between mt10 mb10">
      <div class="flex">

      </div>
      <div>
        <el-button type="primary" @click="add('0')">新增</el-button>
        <el-button type="primary" @click="CloseCurrentTab()">关闭</el-button>
      </div>
    </div>
    <div style="flex: 1;overflow: auto;">
      <el-table :data="tableData" ref="fwdxdata" border stripe @row-click="getrow" height="100%"
        :row-class-name="tableRowClassName" highlight-current-row>
        <el-table-column label="序号" width="50" header-align="center" align="center" show-overflow-tooltip fixed="left">
          <template scope="scope">
            <span>{{ (currentpage - 1) * pagesize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="填报日期" prop="rq" width="120" header-align="center" show-overflow-tooltip fixed="left" />
        <el-table-column label="成人疫苗" prop="ym" width="200" header-align="center" show-overflow-tooltip />
        <el-table-column label="接种率" prop="jzl" width="120" header-align="center"  align="right" show-overflow-tooltip />
        <el-table-column label="创建时间" align="center" prop="create_time" width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.create_time) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="创建人" width="80" header-align="center" prop="create_by" show-overflow-tooltip />
        <el-table-column></el-table-column>
        <el-table-column label="操作" width="100" align="center" fixed="right"  >
          <template scope="scope">
            <el-link type="primary" class="ml10" @click="add(scope.row.id )">修改</el-link>
            <el-link type="primary" class="ml10" @click="handleDelete(scope.row )">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="mb5" v-show="total > 0">
      <pagination :total="total" :page.sync="currentpage" :limit.sync="pagesize" @pagination="getList()()" />
    </div>
    <edit :dialogedit.sync="dialogedit" :id="id+''" @reload="getList" />
  </div>
</template>
<script>
  import {
    list,
    del
  } from '@/api/jkgl/cryml';
  import edit from './edit';
  export default {
    name: "Crymjzl",
    components: {
      edit
    },
    data() {
      return {
        total: 0,
        currentpage: 1,
        pagesize: 100,
        tableData: [],
        // 查询参数
        queryParams: {},
        id: '',
        getindex: -1,
        dialogedit: false
      };
    },
    computed: {},
    created() {
      this.getList();
    },
    mounted() {

    },
    methods: {
      tableRowClassName({
        row,
        rowIndex
      }) {
        row.index = rowIndex;
      },
      getrow(row) {
        this.getindex = row.index;
      },
      add(id) {
        this.id = id;
        this.dialogedit = true;
      },
      handleDelete(row) {
        const rq = row.rq;
        const ym = row.ym;
        var Params = {
          id: row.id
        }
        this.$modal
          .confirm(`是否确认删除?疫苗:${ym}？`)
          .then(function() {
            return del(Params);
          })
          .then(() => {
            this.fileter_cx();
            this.$modal.msgSuccess('删除成功');
          })
          .catch(() => {});
      },
      // 部门
      fileter_cx() {
        this.currentpage = 1;
        this.getList();
      },
      getList() {
        this.getindex = -1;
        this.tableData = [];
        var params = {
          page: this.currentpage,
          pagesize: this.pagesize
        }
        params = this.ObjParams(this.queryParams, params);

        list(params).then(res => {
          this.tableData = res.rows;
          this.currentpage = parseInt(res.currentpage);
          this.total = parseInt(res.total);

        });
      }
    }
  };
</script>
